import random

rule={1:"石头",2:"剪刀",3:"布"}

def judge(person,computer):#判断胜负
    print("你出的是：{}".format(rule[person]))
    print("电脑出的是：{}".format(rule[computer]))
    result = person-computer
    if(result == 1 or result == -2):
        return -1
    elif(result == 0):
        return 0
    else:
        return 1

def IsGameOver(rounds,youwinround,computerwinround):#判断游戏是否结束
    if(youwinround >= (rounds+1)/2):
        return 1
    elif(computerwinround >= (rounds+1)/2):
        return -1
    else:
        return 0

rounds = int(input("请输入希望比赛的轮数："))#比赛的总局数
currentround = 0#当前局数
youwinround = 0#玩家赢的局数
computerwinround = 0#电脑赢的局数
while currentround<rounds:
    print("round:{}".format(currentround))
    print("你赢了:{}局".format(youwinround))
    print("电脑赢了:{}局".format(computerwinround))
    person=0
    while(person<1 or person >3):
        person=int(input("你准备出：1.石头 2.剪刀 3.布\t"))    
    computer = random.randint(1,3)
    result = judge(person,computer)
    if(result==0):
        print("平局，继续比赛！")
        print("--------------------------------------------")
    elif(result==1):
        youwinround = youwinround + 1
        print("你赢了一局！")
        print("--------------------------------------------")
        currentround = currentround + 1
    else:
        computerwinround = computerwinround + 1
        print("电脑赢了一局")
        print("--------------------------------------------")
        currentround = currentround + 1
    allresult=IsGameOver(rounds,youwinround,computerwinround)
    if(allresult==1):
        print("当前进行的是{0}局{1}胜制比赛".format(rounds,int((rounds+1)/2)))
        print("一共进行了{}局比赛（平局不算）".format(currentround))        
        print("你赢了:{}局".format(youwinround))
        print("电脑赢了:{}局".format(computerwinround))
        print("恭喜你，你赢得了胜利！")
        break
    elif(allresult==-1):
        print("当前进行的是{0}局{1}胜制比赛".format(rounds,int((rounds+1)/2)))
        print("一共进行了{}局比赛（平局不算）".format(currentround))        
        print("你赢了:{}局".format(youwinround))
        print("电脑赢了:{}局".format(computerwinround))
        print("你输了，电脑赢得了胜利！")
        break